package com.aloha.springframework.aop.framework.autoproxy;

import com.aloha.springframework.aop.*;
import com.aloha.springframework.aop.framework.ProxyFactory;
import com.aloha.springframework.beans.BeansException;
import com.aloha.springframework.beans.PropertyValues;
import com.aloha.springframework.beans.factory.BeanFactory;
import com.aloha.springframework.beans.factory.BeanFactoryAware;
import com.aloha.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import com.aloha.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
import com.aloha.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.aopalliance.aop.Advice;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author DaiZhiHeng
 * @description 用来组装切面
 * @date 2023/7/7 13:31
 */
public class DefaultAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {

    @Override
    protected List<Advisor> findEligibleAdvisors(Class<?> beanClass, String beanName) throws BeansException {
        return beanFactory.getBeansOfType(PointcutAdvisor.class).values().stream().filter(advisor -> advisor.getPointcut().getClassFilter().matches(beanClass)).collect(Collectors.toList());
    }
}
